
import { Channel, Note } from './note';

class App {

  zrender = null;

  /** @type {Channel[]} */
  channels = [];

  constructor (context) {
    this.context = context;

    // 生成 channels
    let pulse1 = new Channel('pulse1');
    pulse1.notes.push(new Note(0, 0.6, 32, 0));
    pulse1.notes.push(new Note(12, 0.4, 32, 0));
    pulse1.notes.push(new Note(14, 0.2, 32, 0));
    pulse1.notes.push(new Note(20, 0.6, 37, 0));
    pulse1.notes.push(new Note(32, 0.4, 37, 0));
    pulse1.notes.push(new Note(34, 0.2, 37, 0));
    
  }

  init (libs) {
    this.zrender = libs.zrender;

    handleDom(this.width, this.height);
    this.zr = libs.zrender.init(document.getElementById('content'));

  }

  destroy () {
		//
	}

	sendStatus () {
		// nothing, 等待被覆盖
  }
  
  collectInfo () {
		return {};
  }
  
  onMessage (key, data) {
    // switch
  }

}

function handleDom(width, height) {
  var main = document.getElementById('main');
  main.style.width = width + 'px';
  main.style.height = height + 'px';
  
  let contentdiv = document.createElement('div');
  contentdiv.id = 'content';
  contentdiv.style.position = 'absolute';
  contentdiv.style.width = width + 'px';
  contentdiv.style.height = height + 'px';
  main.appendChild(contentdiv);
}

export default App;

